package com.cuihanyu.newuniversityover.activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;

import com.cuihanyu.newuniversityover.R;
import com.cuihanyu.newuniversityover.util.SPUtils;

/**
 * Created by Administrator on 2017/5/15 0015.
 */

public class JoinActivity extends AppCompatActivity {
    ImageView imageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.join_image);
        imageView = (ImageView) findViewById(R.id.imageView);
        RotateAnimation animation = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        animation.setDuration(1000);
        imageView.setAnimation(animation);
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {  //动画执行过后执行的方法
                jumpNextPage();

            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
    }

    private void jumpNextPage() {
        //判断之前有没有新手指导
        boolean userGuide = (boolean) SPUtils.get(JoinActivity.this, "is_user_guide_showed", false);
        //跳转进入新手界面
        if (!userGuide) {
            Intent intent = new Intent(JoinActivity.this, GuidanceActivity.class);
            startActivity(intent);
        } else {
            Intent intent = new Intent(JoinActivity.this, MainActivity.class);
            startActivity(intent);
        }
        finish();//跳转过去后销毁动画
    }
}
